package com.sqx.modules.errand.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.common.utils.Result;
import com.sqx.modules.app.service.UserService;
import com.sqx.modules.errand.dao.EvaluateDao;
import com.sqx.modules.errand.entity.Evaluate;
import com.sqx.modules.errand.service.EvaluateService;
import com.sqx.modules.errand.service.IndentService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EvaluateServiceImpl extends ServiceImpl<EvaluateDao, Evaluate> implements EvaluateService {

    @Autowired
    private UserService userService;
    @Autowired
    private IndentService indentService;


    @Override
    public Result selectEvaluate(Integer page, Integer limit,String nickName,String riderName,Long userId,Long riderUserId,String satisfactionFlag,String indentNumber) {
        Page<Evaluate> pages = new Page<>(page, limit);
        IPage<Evaluate> evaluateIPage = baseMapper.selectEvaluateList(pages, nickName, riderName, userId,riderUserId, satisfactionFlag, indentNumber);
        List<Evaluate> records = evaluateIPage.getRecords();
        for(Evaluate evaluate:records){
            evaluate.setUser(userService.getById(evaluate.getUserId()));
            evaluate.setRiderUser(userService.getById(evaluate.getRiderUserId()));
            evaluate.setIndent(indentService.findIndentByIndentNumber(evaluate.getIndentNumber()));
        }
        return Result.success().put("data", evaluateIPage);
    }

    /*@Override
    public Result findEvaluate(Long userId) {
        baseMapper.insert();
        baseMapper.selectById();
        baseMapper.selectList(new QueryWrapper<Evaluate>().eq("user_id",userId));
        baseMapper.deleteById();
        baseMapper.updateById();

    }*/





}
